package cn.tmz.at;

import java.util.Arrays;

public class BubblingSort {

    public static void main(String[] args) {
        int[] arr = {8, 5, 3, 7, 1, 9, 2};
        System.out.println("Before sorting:");
        System.out.println(Arrays.toString(arr));
        bubblingSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    private static void bubblingSort(int arr[]){
        int end = arr.length;
        int start = 0;
        for (int i = start; i < end; i++) {
            for (int j = i+1; j < end; j++) {
                if(arr[i]>arr[j]){
                    int temp = arr[j] ^ arr[i];
                    arr[j] = temp ^ arr[j];
                    arr[i] = temp ^ arr[j];
                   /* int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;*/
                }
            }
        }
    }
}
